import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;

class PersonOverride{
    private String name;
    private int age;
    private boolean gender;
PersonOverride(String name,int age,boolean gender){
    this.name = name;
    this.age=age;
    this.gender = gender;
}
PersonOverride(){
    this("default",1,true);
}

    @Override
    public String toString() {
       return name+"-"+age+"-"+gender;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PersonOverride that = (PersonOverride) o;
        return age == that.age && gender == that.gender && Objects.equals(name, that.name);
    }


}
public class Mai {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n1 = sc.nextInt();
        boolean f=true;
        sc.nextLine();
      ArrayList<PersonOverride> persons1=  new ArrayList<>();
        for(int i=0;i<n1;i++){
            persons1.add(new PersonOverride());
        }
    int n2 = sc.nextInt();
        sc.nextLine();
        for(int i=0;i<n2;i++){
            f=true;
            PersonOverride a = new PersonOverride(sc.next(),sc.nextInt(),sc.nextBoolean());
          sc.nextLine();
            for(PersonOverride p:persons1){
                if(p.equals(a)){
                    f=false;
                    break;
                }
            }
            if(f){
                persons1.add(a);
            }
        }
        for(PersonOverride p:persons1){
            System.out.println(p.toString().replace("[","").replace("]",""));

        }
        System.out.println(persons1.size()-n1);
        System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));

    }

}
